package com.sky.task;

import com.alibaba.fastjson.JSONObject;
import com.sky.websocket.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class MyTask {
    @Autowired
    private WebSocketServer webSocketServer;
  //  @Scheduled(cron = "0/5 * * * * ?")//每五秒执行一次
    public void testTask(){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("type",1);
        jsonObject.put("orderId",123456789);
        jsonObject.put("content","订单号:"+"123456789");
        webSocketServer.sendToAllClient(jsonObject.toJSONString());
    }
}
